import threading
import testScript

url = 'http://192.168.0.201/new/#/login'

def run_automation_flow(username, password, pay_password, url, dept_name, type):
    # 这里是run_automation_flow的具体实现
    testScript.recurrent_execution(username, password, pay_password, url, dept_name, type)
    print(f"Running automation flow for dept_name {dept_name}")

# 假设我们有一系列的用户名和密码
users_credentials = [
    # username  password   pay_password url,dept_name  type(0--含服务费，1--不含服务费)
    ('一体化01', 'Y123456', 'Y123456', url, '一体化结算压测大同市公司', '1'),
    ('一体化02', 'Y123456', 'Y123456', url, '一体化结算压测衡水市公司', '1'),
    ('一体化03', 'Y123456', 'Y123456', url, '一体化结算压测邢台市公司', '1'),
    ('一体化04', 'Y123456', 'Y123456', url, '一体化结算压测宜宾市公司', '1'),
    ('一体化05', 'Y123456', 'Y123456', url, '一体化结算压测邯郸市公司', '1'),
    ('一体化06', 'Y123456', 'Y123456', url, '一体化结算压测杭州市公司', '1'),
    ('一体化007', 'Y123456', 'Y123456', url, '一体化结算压测上海市公司', '1'),
    ('一体化008', 'Y123456', 'Y123456', url, '一体化结算压测大洋洲分公司', '1'),
    ('一体化009', 'Y123456', 'Y123456', url, '一体化结算压测亚洲分公司', '1'),
    ('一体化010', 'Y123456', 'Y123456', url, '一体化结算压测非洲分公司', '1'),
    # ('一体化011', 'Y123456', 'Y123456', url, '一体化结算压测南极分公司', '1'),
    # ('一体化012', 'Y123456', 'Y123456', url, '一体化结算压测北极分公司', '1'),
    # ('一体化013', 'Y123456', 'Y123456', url, '一体化结算压测东南亚分公司', '1'),
    # ('一体化14', 'Y123456', 'Y123456', url, '一体化结算压测美欧分公司', '1'),
    # ('一体化15', 'Y123456', 'Y123456', url, '一体化结算压测牡丹江市公司', '1'),
    # ('一体化16', 'Y123456', 'Y123456', url, '一体化结算压测北京市公司', '1'),
    # ('一体化17', 'Y123456', 'Y123456', url, '一体化结算压测石家庄市公司', '1'),
    # ('一体化18', 'Y123456', 'Y123456', url, '一体化结算压测四平市公司', '1'),
    # ('一体化19', 'Y123456', 'Y123456', url, '一体化结算压测孝感市公司', '1'),
    # ('一体化20', 'Y123456', 'Y123456', url, '一体化结算压测泉州市公司', '1'),
]

# 为每个用户创建并启动一个线程
def createThreadAndRun():
    threads = []
    for credentials in users_credentials:
        username, password, pay_password, url, dept_name, type = credentials
        thread = threading.Thread(target=run_automation_flow, args=(username, password, pay_password, url, dept_name, type))
        threads.append(thread)
        thread.start()

    # 等待所有线程完成
    for thread in threads:
        thread.join()

    print("All automation flows completed.")

createThreadAndRun()